package com.hbgc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hbgc.mapper.TbSpiderMapper;
import com.hbgc.pojo.TbSpider;
import com.hbgc.pojo.TbVideo;
import com.hbgc.service.ISpiderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpiderServiceImpl implements ISpiderService {

    @Autowired
    private TbSpiderMapper tbSpiderMapper;

    @Override
    public PageInfo queryTbSpiderByPage(int pageNow, int pageSize, String spidername) {
        PageHelper.startPage(pageNow,pageSize);
        List<TbSpider> tbSpiders = tbSpiderMapper.selectAllBySpidername(spidername);
        PageInfo pageInfo=new PageInfo(tbSpiders);
        return pageInfo;
    }

    @Override
    public List<TbSpider> queryAll() {
        return    tbSpiderMapper.selectAllBySpidername("");
    }

    @Override
    public boolean saveTbSpider(TbSpider tbSpider) {
        return tbSpiderMapper.insert(tbSpider)>0?true:false;
    }

    @Override
    public boolean updateTbSpiderById(TbSpider tbSpider) {
        return tbSpiderMapper.updateByPrimaryKey(tbSpider)>0?true:false;
    }

    @Override
    public boolean deleteTbSpiderById(Long spiderid) {
        return tbSpiderMapper.deleteByPrimaryKey(spiderid)>0?true:false;
    }

    @Override
    public TbSpider getTbSpiderById(Long spiderid) {
        return tbSpiderMapper.selectByPrimaryKey(spiderid);
    }
}
